POV-Ray : Newsgroups : povray.binaries.images : Underwater : Re: Underwater Server Time
7 Aug 2024 01:26:56 EDT (-0400)
  Re: Underwater  
From: Trevor G Quayle
Date: 14 Jul 2006 09:40:00
Message: <web.44b79e3341c8db3cc150d4c10@news.povray.org>
"Gail Shaw" <initialsurname@sentech sa dot com> wrote:
> "Trevor G Quayle" <Tin### [at] hotmailcom> wrote in message
> news:web.44b78e99dec2fd42c150d4c10@news.povray.org...
> > Lately I've been participating in the lighting challenges hosted by Jeremy
> > Birn over at CGTalk (http://forums.cgsociety.org/forumdisplay.php?f=185).
> > (I have a feeling that I may be the only POVer there at the moment,
> > everyone elseseems to be using commercial level progs)
> > Anyways, here is one of my latest entries in the latest challenge that I
> > wanted to share here.
>
> Very nice. I've been plyaing with underwater scenes recently, but haven't
> had much success
>
> Would you be willing to share the code for the water please?

Sure.
A few notes:
The surface is just normals with ripple center locations manually enteredfor
objects penetrating the surface.  The parameters used for N1 need to be
adjusted according to the look you want and the scale of your scene.
The water color itself is perfectly clear (rgbt 1) and light attenuation is
not on.  All light colouring and attenuation comes from the absorption
media which I tried to tweak based on some actual water/light parameters
(http://www.seafriends.org.nz/phgraph/water.htm#colour if you would like an
interesting read).  The caustics were faked using a bitmap filter just above
the water surface. (Caustic map obtained
fromhttp://www.dgp.toronto.edu/%7Estam/reality/Research/PeriodicCaustics/index.html)

//START
global_settings{number_of_waves 10 }
#declare NP=21;//number of items making ripples

#declare P0=normal{granite bump_size NP/20 scale 2}

#macro N1(OS,SCL,FRQ,SIZ,BS)//ripple macro
  cylindrical
  normal_map{[0.0 bozo 0] [1.0 ripples bump_size BS*NP scale SIZ/SCL
frequency SIZ*FRQ]}
  poly_wave 1.5
  scale SCL
  translate OS
#end

#declare PLoc0=<-7.3,9,-25.9>;//Pier Locations
#declare PLoc1=< 7.3,9,-25.9>;
#declare PLoc2=< 7.3,9, -6.6>;
#declare PLoc3=<-7.3,9, -6.6>;
#declare PLoc4=< 7.3,9, 17.0>;
#declare PLoc5=<-7.3,9, 17.0>;
#declare PLoc6=< 7.3,9, 40.7>;
#declare PLoc7=<-7.3,9, 40.7>;
#declare PT1=<3.2,0,-24.5>;//PAD1
#declare PT2=<3.6,0,-26.6>;//PAD2
#declare PT3=<5.8,0,-24.9>;//PAD3
#declare PT4=<5.4,0,-30.8>;//FLOAT
#declare PT5=<0.4,0,-32.9>;//PLANT
#declare PT6=<2.0,0,-32.1>;//PLANT
#declare PT7=<1.5,0,-34.0>;//PLANT
#declare PT8=<0.7,0,-32.2>;//PLANT
#declare PT9=<11.6,0,-22.0>;//PLANT
#declare PT10=<11.8,0,-22.8>;//PLANT
#declare PT11=<13.0,0,-20.9>;//PLANT

#declare P1= //ripple normal map
  normal {
    average
    normal_map {
      [1 N1(PLoc0,12,3,0.5,1)]
      [1 N1(PLoc1,12,3,0.5,1)]
      [1 N1(PLoc2,12,3,0.5,1)]
      [1 N1(PLoc3,12,3,0.5,1)]
      [1 N1(PLoc4,12,3,0.5,1)]
      [1 N1(PLoc5,12,3,0.5,1)]
      [1 N1(PLoc6,12,3,0.5,1)]
      [1 N1(PLoc7,12,3,0.5,1)]
      [1 N1(0,20,2,1.0,1) scale <1,1,2> rotate -y*13 translate
<-14.4,0,-13.4>]//BOAT
      [1 N1(PT1,10,5,0.2,1)]//PAD1
      [1 N1(PT2,10,5,0.2,1)]//PAD2
      [1 N1(PT3,10,5,0.2,1)]//PAD3
      [1 N1(PT4,5,20,0.3,1)]//FLOAT
      [1 N1(PT5,5,20,0.3,1)]//PLANT
      [1 N1(PT6,5,20,0.3,1)]//PLANT
      [1 N1(PT7,5,20,0.3,1)]//PLANT
      [1 N1(PT8,5,20,0.3,1)]//PLANT
      [1 N1(PT9,5,20,0.3,1)]//PLANT
      [1 N1(PT10,5,20,0.3,1)]//PLANT
      [1 N1(PT11,5,20,0.3,1)]//PLANT
      [1.5 P0]
    }
  }


#declare MWater=
  material{
    texture{
      pigment{rgbt 1}
      finish{conserve_energy  diffuse 0  ambient 0  reflection{0 1 fresnel
on metallic 0}}
      normal{P1}
    }
    #local FD=-(1000/(6*25.4))/ln(0.58)*2;
    interior{
      ior 1.33
      media{//light absorption
        absorption rgb 1-<0.51373, 0.70588, 0.59216>
        density{rgb 1/FD}
      }
      media{//light scattering
        method 3
        samples 50,100
        jitter 0.5
        scattering{4,rgb <0.74118, 0.71765, 0.41961>}
        density{
          bozo
            color_map {
              [0.0 rgb 1/100]
              [1.0 rgb 1/200]
            }
            scale 1/2
        }
      }
    }
  }

#declare WaterSurface2=box{<-202,-2,-234><202,8.14,91> hollow}


object{WaterSurface2 hollow
  material{MWater}
//  photons{target refraction on reflection on collect off}
}

//faked caustics
#local PIMAGE = function {pigment{image_map {sys "Caus.bmp" interpolate
2}rotate x*90 scale 10}}
plane{y 0 pigment{function{PIMAGE(x,y,z).gray} colour_map{[0 rgbt 0][1 rgbt
2]}}   translate y*8.141 hollow no_image no_reflection}

//END

-tgq


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.